In [1]:
%matplotlib inline
import cPickle as pickle
from IPython.html.widgets import interact, IntSliderWidget, DropdownWidget
from IPython.display import display, HTML
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
from path_helpers import path
# Load experiment log data into `log` variable.
log_root = path('.').abspath()
log_path = log_root.joinpath('data')
log = log_path.pickle_load()
print 'Read log data from: %s' % log_path
# Create widgets that we'll display below to navigate log data.
def index_selected(name, index):
dropdown.values = dict([(k, pickle.loads(v))
for k, v in log.data[index].iteritems()])
index_widget = IntSliderWidget(min=0, max=len(log.data) - 1)
index_widget.value = index_widget.min
# Update the plugin dropdown list whenever log index is changed.
index_widget.on_trait_change(index_selected, 'value')
dropdown = DropdownWidget(label='Plugin')
index_selected('value', index_widget.value)
log.data
is a list containing log data for each step. Note that the first
entry (i.e., at index 0) does not correspond to a step, but instead contains
details about hardware and software versions used for the experiment.
Each log entry contains a dictionary mapping each plugin name to its corresponding data for the step.
The data for each plugin is serialized using the Python pickle
library.
To load the step data for plugin, we can "unpickle" the corresponding dictionary
entry.
For example, the interactive demo below can be used to load and display the data for each log entry by plugin name. Drag the slider to change the entry index.
In [2]:
import pprint
def summarize(data):
summary = pprint.pformat(data)
if len(summary) > 1000:
summary = summary[:1000] + '...'
return summary
def display_plugin_names(index=0):
data_i = log.data[index]
for plugin_name, plugin_pickled_data in data_i.iteritems():
display(HTML('<h2>%s</h2>' % plugin_name))
plugin_data = pickle.loads(plugin_pickled_data)
print summarize(plugin_data)
interact_function = interact(display_plugin_names, index=(0, len(log.data) - 1))
We saw above how to navigate through summaries of the experiment log data, but we can also select data for further analysis.
Using the widgets below, the data for a particular plugin at a chosen log index
may be chosen. The data is then available through the value
attribute of the
dropdown
variable.
In [3]:
def display_data(plugin_data=None):
print summarize(plugin_data)
return plugin_data
display(index_widget)
interact(display_data, plugin_data=dropdown)
pass
In [4]:
dropdown.value
Out[4]: